package bookworm;

import java.net.URL;
import java.net.URLConnection;

/**
 * this class will test if the user's computer has a proper Internet connection.
 * Some functionalities of our system require Internet connection, so this class will
 * check the connection before these features can be executed.
 *
 */
public class TestIfUserIsConnected 
{
	public static boolean hasInternetConnection()
	{
		try
		{
			final URL url = new URL("http://www.google.com");
			final URLConnection conn = url.openConnection();
			conn.connect();
			//if we got here, we should have net... 
			return true;
		}
		catch(Exception exc)
		{
			return false;//nope, no Internet connection
		}
	}

}
